package com.dreamcode.anfeedreader.collectors;

import java.util.List;

import android.content.Context;
import android.graphics.Color;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.dreamcode.anfeedreader.activity.R;
import com.dreamcode.anfeedreader.modelClass.FeedItem;

public class FeedListAdapter extends BaseAdapter{

	private List<FeedItem> feedItems = null;
	private Context ctx;
	public FeedListAdapter(Context ctx, List<FeedItem> feedItems){
		this.ctx = ctx;
		this.feedItems = feedItems;
	}
	
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return feedItems.size();
	}

	@Override
	public Object getItem(int pos) {
		// TODO Auto-generated method stub
		return feedItems.get(pos);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		final LinearLayout lView = new LinearLayout(ctx);
		lView.setId((feedItems.get(position)).getId());
		lView.setMinimumHeight(25);
		lView.setGravity(Gravity.CENTER_VERTICAL);
		/*RadioButton radioItem = new RadioButton(ctx);
		radioItem.setText((categoryList.get(position)).getGroupName());*/
		TextView tView = new TextView(ctx);
		tView.setGravity(Gravity.CENTER_VERTICAL);
		tView.setText((feedItems.get(position)).getTitle());
		tView.setBackgroundResource(R.drawable.bg_color5);
		tView.setMinHeight(30);
		tView.setWidth(300);
		if((feedItems.get(position)).getStatus().equals("0"))
			tView.setTextColor(Color.BLACK);
		else if((feedItems.get(position)).getStatus().equals("1"))
			tView.setTextColor(Color.GRAY);
		else if((feedItems.get(position)).getStatus().equals("2"))
			tView.setTextColor(Color.RED);
		lView.addView(tView);
		return lView;
	}

}
